#include "epd_app.h"
#include "py32f0xx_hal.h"
#include "gpio.h"

void epd_app_init(void) {
    PY_GPIO_Init();
    EPD_GPIO_Init();
}

void epd_app_process(void) {
    EPD_HW_Init();           // Full screen update initialization.
    EPD_WhiteScreen_Black(); // Clear screen function.
    EPD_DeepSleep();         // Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
    HAL_Delay(2000);         // Delay for 2s.
    HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_1);

    EPD_HW_Init();           // Full screen update initialization.
    EPD_WhiteScreen_White(); // Clear screen function.
    EPD_DeepSleep();         // Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
    HAL_Delay(2000);         // Delay for 2s.
    HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_1);

    EPD_HW_Init();                           // Electronic paper initialization.
    EPD_SetRAMValue_BaseMap(gImage_basemap); // Please do not delete the background color function, otherwise it will cause unstable display during partial update.
    for (uint8_t i = 0; i < 60; i++)
        EPD_Dis_Part_Time(32, 56 + 24 * 0, Num[i%10],          // x-A,y-A,DATA-A
                          32, 56 + 24 * 1, Num[i/10],          // x-B,y-B,DATA-B
                          32, 56 + 24 * 2, gImage_numdot,   // x-C,y-C,DATA-C
                          32, 56 + 24 * 3, Num[0],          // x-D,y-D,DATA-D
                          32, 56 + 24 * 4, Num[1], 24, 32); // x-E,y-E,DATA-E,Resolution 24*32

    EPD_DeepSleep();               // Enter the sleep mode and please do not delete it, otherwise it will reduce the lifespan of the screen.
    HAL_Delay(2000);               // Delay for 2s.
    HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_1);
}